package sl1;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Test {
    public static void main(String[] args) throws Exception {
        Class clz = Class.forName("sl1.Apple");
        if(clz.isAnnotationPresent(Component.class)){
            Component component = (Component) clz.getAnnotation(Component.class);
            String value = component.value();
            System.out.println(value);
        }
        Class clz2 = Class.forName("sl1.Apple");
        Field brand = clz2.getDeclaredField("brand");
        if(brand.isAnnotationPresent(Resource.class)){
            Resource resource = (Resource) brand.getAnnotation(Resource.class);
            String name = resource.name();
            System.out.println(name);
        }
        Class clz3 = Class.forName("sl1.Apple");
        Method getBrand = clz3.getDeclaredMethod("getBrand");
        if(getBrand.isAnnotationPresent(RequestMapping.class)){
            RequestMapping requestMapping = (RequestMapping) getBrand.getAnnotation(RequestMapping.class);
            String value = requestMapping.value();
            String method = requestMapping.method();
            System.out.println(value+","+method);
        }
    }
}
